package edu.pitt.myptm.datamanager;

import java.util.Hashtable;

import edu.pitt.myptm.DataItem;

public class MyBuffer {
	private int bufferSize;
	
	public int getBufferSize() {
		return bufferSize;
	}
	
	public void setBufferSize(int bufferSize) {
		this.bufferSize = bufferSize;
	}
	int maxItemCount = 0;
	
	public MyBuffer(int bufferSize) {
		this.bufferSize = bufferSize;
		maxItemCount = bufferSize/(DataItem.getItemSize()+4);
		memContent = new Hashtable<Integer,DataItem>();
	}
	
	private Hashtable<Integer,DataItem> memContent ;
	
	public DataItem queryContent(int id) {
		if(memContent.containsKey(id)) 
		return memContent.get(id);
		return null;
	}
	
	public void addDataItem(DataItem item) {
		int id = item.getId();
		memContent.put(id, item);
		if(memContent.size()>=maxItemCount) {
			clearBuffer();
		}
	}
	
	public void clearBuffer() {
		
	}
}
